Modern software developers often develop software programs initially in a source code format. Thereafter, a compiler typically processes the source code to generate an executable program in an intermediate language code or executable code format. A compiler may also compile intermediate language code into an executable code format. A translation from one format to another provides the opportunity to introduce optimizations into the resulting code. For example, the compiler can examine the source code and modify the code to use computer resources more efficiently or to provide better runtime performance.
One of the more expensive runtime operations in object oriented languages is referred to as “indirect method invocation”, through which a method call site may call one of several possible methods. The selection of which method is actually called is deferred until runtime and depends on the runtime type of the receiver object. For example, consider the type hierarchy 100 shown in FIG. 1, which has an abstract parent class “Statement” 102 having virtual methods: (1) getName( ) and (2) getKind( ). “Type” is a generalization of “class,” “interface,” etc. The parent type “Statement” 100 has an abstract child type “Effect” 104 and a concrete child type “Control” 106. The type “Effect” 104 has two concrete child types “Assignment” 108 and “SideEffect” 110. The methods getName( ) and getKind( ) for each of the concrete types return constant values and have no side effects. Also, the method addKindPlusOne( ) of SideEffect 110 also returns a constant value.
With regard to the type hierarchy of FIG. 1, indirect method invocation relates to execution of exemplary code:
(1) Statement stmt=. . . ;
(2) String s=stmt.getName( );